	$(function(){
		//边换主题颜色
		var model=localStorage.model;
		console.log(model);
		if(model==1){
			$('#homePageXJ').css('background','#535a7e');
		}else if(model==2){
			$('#homePageXJ').css('background','#129b63');
		}	
	});
	
//	//视频
//	var num = Math.random();
//	num = Math.ceil(num * 9);
//	console.log(num);
//	$.ajax({
//		  url:'../homeinformation/homePageInfoForXJ',
//		  type:'POST', 
//		  async:false,
//		  success:function(data){
//			  $('#video').html('');
//		      $('#video').append("<video id='videos' style='position: relative;z-index: 10;' src="+data[4].videos[num]+" type='video/mp4'  autoplay width='100%' height='255px'>");
//		  }
//	});
//	//播放下一步
//	
//    function videoNext(){
//   	 $.ajax({
//			  url:'../homeinformation/homePageInfoForXJ',
//			  type:'POST', 
//			  async:false,
//			  success:function(data){
//				  $('#video').html('');
//			      $('#video').append("<video id='videos' style='position: relative;z-index: 10;' src="+data[4].videos[num]+" type='video/mp4'  autoplay width='100%' height='255px'>");
//			  }
//   	 });
//   }
//   var video = document.getElementById("videos");
//   video.addEventListener("ended", function() { // 对视频播放添加结束事件，播放结束后调用videoNext()方法
//       videoNext();
//       num = Math.random();
//       num = Math.ceil(num * 9); 
//   }, false); 
//   
//   
//	//图片
//	var length;
//	//获取图片地址
//	$.ajax({
//		url:'../wetlandManager/findWetlandPictureForBD',
//		type:'POST',
//		success:function(res){
//			for(var i=0;i<res.length;i++){
//				length=res.length;
//		        var nums = Math.random();
//		        nums = Math.ceil(nums * length);
//				if(i==0){
//					$('#image').append("<img src="+res[0]+"   class='active'/'>");
//
//				}
//				$('#image').append("<img src="+res[nums]+" />");
//			}
//		},
//		error:function(e){
//			console.log(e); 
//		}
//	})
//	
//	//图片轮播
//	function slideshow() {
//	  var slideshow=document.getElementById("image"),
//	  imgs=slideshow.getElementsByTagName("img"), //得到图片们
//	  current=0; //current为当前活跃的图片编号
//	
//	  function slideOff() {
//	    imgs[current].className=""; //图片淡出
//	  }
//	  function slideOn() {
//	    imgs[current].className="active"; //图片淡入
//	  }
//	
//	  function changeSlide() { //切换图片的函数
//	    slideOff(); //图片淡出
//	    current++; //自增1
//	    if(current>=length) current=0;
//	    slideOn(); //图片淡入
//	  }
//	  
//	  //每2s调用changeSlide函数进行图片轮播
//	  var slideon=setInterval(changeSlide,6000);  
//	}
//    slideshow();
		 $.ajax({
			  url:'../homeinformation/homePageInfoForXJ',
			  type:'POST', 
			  async:false,
			  success:function(data){
				 for(var i=0;i<data.length;i++){
					 if(data[i].picturetype=='bar1'){
						//保护级别图表设置
						var myChart = echarts.init(document.getElementById('protection_class'));
						option = {
					    tooltip : {
					        trigger: 'axis',
					        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
					            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
					        },
	  				        formatter: function(prams) {
	  				        	var datas='';
	  				        	for(var i=0;i<prams.length;i++){
	  				        		var name=prams[i].seriesName.split('（')[0];
	  				        		var data=name+':'+prams[i].data+'个</br>';
	  				        		datas+=data;
	  				        	}
	  				        	return datas;
	  				        }
					    },
					    legend: {
					        data:[data[i].names[0]+"     ",data[i].names[1],data[i].names[4]+"     ",data[i].names[3],data[i].names[2]],
					        left:'10%',
					        textStyle:{
					        	color:'#fff'
					        }
					    },
					    grid: {
					        left: '3%',
					        right: '4%',
					        top:'30%',
					        bottom: '11%',
					        containLabel: true
					    },
					    xAxis : [
					        {
					            type : 'category',
					            data : data[i].xaxis,
					            axisLabel:{
					                //X轴刻度配置
					                interval:0,//0：表示全部显示不间隔；auto:表示自动根据刻度个数和宽度自动设置间隔个数
					                rotate:30,
					                margin:5,
					                textStyle:{
					                	  color: function (value, index) {
					                          return value.length >0 ? '#fff' : 'red';                   
					                      },
					                      fontSize:11
					                }
					              
					           },
					        }
					    ],
					    yAxis : [
					        {
					            type : 'value',
					            axisLabel:{             
					            	 textStyle:{
					               	  color: function (value, index) {
					                         return value.length >0 ? '#fff' : 'red';                   
					                     },             
					               }            
					           },
					          
					        }
					    ],
					    series : [
					        {
					            name:data[i].names[0]+"     ",
					            type:'bar',
					            barWidth:15,
					            stack: '湿地',
					            data:data[i].rawdata[0],
					            itemStyle:{
					            	normal:{
					            		   color: '#2e87c9'
					            	}
					            }
					        },
					        {
					            name:data[i].names[1],
					            type:'bar',
					            stack: '湿地',
					            data:data[i].rawdata[1],
					            itemStyle:{
					            	normal:{
					            		   color: '#77bdf2'
					            	}
					            }
					        },
					        {
					            name:data[i].names[4]+"     ",
					            type:'bar',
					            stack: '湿地',
					            data:data[i].rawdata[4],
					            itemStyle:{
					            	normal:{
					            		   color: '#aecf9a'
					            	} 
					            }
					        },
					        {
					            name:data[i].names[3],
					            type:'bar',
					            stack: '湿地',
					            data:data[i].rawdata[3],
					            itemStyle:{
					            	normal:{
					            		   color: '#90b7dc'
					            	}
					            }
					        },

					        {
					            name:data[i].names[2],
					            type:'bar',
					            stack: '湿地',
					            data:data[i].rawdata[2],
					            itemStyle:{
					            	normal:{
					            		   color: '#90b7dc'
					            	}
					            }
					        },
					       
					    ]
					};
						myChart.setOption(option); 
				}else if(data[i].picturetype=='bar2'){
					//保护形式图表设置
					 var myChart2 = echarts.init(document.getElementById('protection_type'));
					var option2 = {
				    tooltip : {
				        trigger: 'axis',
				        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
				            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
				        },
 				        formatter: function(prams) {
 				        	var datas='';
 				        	for(var i=0;i<prams.length;i++){
 				        		var name=prams[i].seriesName.split('（')[0];
 				        		var data=name+':'+prams[i].data+'个</br>';
 				        		datas+=data;
 				        	}
 				        	return datas;
 				        }
				    },
				    legend: {
				    	data:[data[i].names[1]+"      ",data[i].names[4],data[i].names[2]+"   ",data[i].names[0],data[i].names[3]],
				        textStyle:{
				        	color:'#fff',
				        	fontSize:12
				        }
				    },
				    grid: {   	    
				        left: '3%',
				        right: '4%',
				        bottom: '6%',
				        top:'30%',
				        containLabel: true
				    },
				    xAxis : [
				        {
				            type : 'category',
				            data : data[i].xaxis,
				            axisLabel:{
				                //X轴刻度配置
				                interval:0,//0：表示全部显示不间隔；auto:表示自动根据刻度个数和宽度自动设置间隔个数
				                rotate:30,
				                margin:5,
				                textStyle:{
				                	  color: function (value, index) {
				                          return value.length >0 ? '#fff' : 'red';                   
				                      },
				                      fontSize:11
				                }
				              
				           },
				        }
				    ],
				    yAxis : [
				        {
				            type : 'value',
				            axisLabel:{             
				            	 textStyle:{
				               	  color: function (value, index) {
				                         return value.length >0 ? '#fff' : 'red';                   
				                     },             
				               }            
				           },
				          
				        }
				    ],
				    series : [
				        {
				            name:data[i].names[0],
				            type:'bar',
				            barWidth:15,
				            stack: '湿地',
				            data:data[i].rawdata[0],
				            itemStyle:{
				            	normal:{
				            		   color: '#2e87c9'
				            	}
				            }
				        },
				        { 
				            name:data[i].names[1]+"      ",
				            type:'bar',
				            stack: '湿地',
				            data:data[i].rawdata[1],
				            itemStyle:{
				            	normal:{
				            		   color: '#77bdf2'
				            	}
				            }
				        },
				        {
				            name:data[i].names[2]+"   ",
				            type:'bar',
				            stack: '湿地',
				            data:data[i].rawdata[2],
				            itemStyle:{
				            	normal:{
				            		   color: '#849f74'
				            	}
				            }
				        },
				        {
				            name:data[i].names[3],
				            type:'bar',
				            stack: '湿地',
				            data:data[i].rawdata[3],
				            itemStyle:{
				            	normal:{
				            		   color: '#aecf9a'
				            	}
				            }
				        },
				        {
				            name:data[i].names[4],
				            type:'bar',
				            stack: '湿地',
				            data:data[i].rawdata[4],
				            itemStyle:{
				            	normal:{
				            		   color: '#90b7dc'
				            	}
				            }
				        }
				    ]
				};
					 myChart2.setOption(option2);
				}else if(data[i].picturetype=='pie1'){

					 //生态监测饼图
					  var myChart3= echarts.init(document.getElementById('monitoring'));
					 var option3 = {
							    title : {
							        text: "站点总数："+data[2].numOfSite+"   指标总数："+data[2].numOfIndicator+"   数据采集总数："+data[2].numOfData+"",			      
							        textStyle:{
							        	color:'#fff',
							        	fontSize:13
							        },				     
							        top:0,
							        left:50
							    },
							    tooltip: {
							        trigger: 'item',
							        formatter: "{a} <br/>{b}: {c} ({d}%)"
							    },
							  
							    series: [
							        {
							            name:'监测类型',
							            type:'pie',
							            radius: ['40%', '60%'],
							            center: ['50%','45%'],
							            avoidLabelOverlap: false,
							            label: { 
							                normal: { 
							                    show: true,
							                    
							                },
							                lableLine: {
							                    normal: {
							                        show: true
							                    }
							                  
							                },
							                emphasis: {
							                    show: true,
							                    textStyle: {
							                        fontSize: '12',
							                        fontWeight: 'bold'
							                    }
							                }
							            },
							            labelLine: {
							                normal: {
							                    show: true
							                }
							            },
							            data:[
							                {value:data[i].rawdata[0], name:data[i].names[0],itemStyle:{normal:{color: '#2e87c9'}}},	                
							                {value:data[i].rawdata[1], name:data[i].names[1],itemStyle:{normal:{color: '#77bdf2'}}},
							                {value:data[i].rawdata[2], name:data[i].names[2],itemStyle:{normal:{color: '#849f74'}}},
							                {value:data[i].rawdata[3], name:data[i].names[3],itemStyle:{normal:{color: '#aecf9a'}}}
							            ]
							        }
							    ]
							};
					 myChart3.setOption(option3)
				}	
			 }

		}
});   
		 
		 //湿地面积饼图
		  var myChart4= echarts.init(document.getElementById('area'));
		 var option4 = {			   
				    tooltip : {
				        trigger: 'item',
				        formatter: "{a} <br/>{b} : {c} ({d}%)"
				    },
				    title : {
				        text: '新疆湿地总面积：176.63（万公顷）',			      
				        textStyle:{
				        	color:'#fff',
				        	fontSize:13
				        },				      
				        top:0,
				        left:'30%'
				    },
				    legend: {
				        orient: 'vertical',
				        x: 'left',
				        top:30,
				        left:30,
				        itemGap:30,
				        data:['河流湿地（38.93万公顷）','湖泊湿地（53.65万公顷）','近海与海岸湿地（9.59万公顷）','人工湿地（71.67万公顷）','沼泽湿地（2.80万公顷）'],
				        textStyle:{
				        	color:'#fff',
				        	fontSize:12
				        }
				    },
				    series : [
				        {
				            name: '湿地',
				            type: 'pie',
				            radius : '65%',
				            center: ['75%', '50%'],			           
				            data:[
				                {value:38.93, name:'河流湿地（38.93万公顷）',itemStyle:{normal:{color: '#77bdf2'}}},
				                {value:53.65, name:'湖泊湿地（53.65万公顷）',itemStyle:{normal:{color: '#2e87c9'}}},
				                {value:9.59, name:'近海与海岸湿地（9.59万公顷）',itemStyle:{normal:{color: '#849f74'}}},
				                {value:71.67, name:'人工湿地（71.67万公顷）',itemStyle:{normal:{color: '#aecf9a'}}},
				                {value:2.80, name:'沼泽湿地（2.80万公顷）',itemStyle:{normal:{color: '#90b7dc'}}}
				            ],	
				            label: {
				                normal: {
				                    show: false,
				                   
				                },
				               
				            },
				            labelLine: {
				                normal: {
				                    show:false,                  		                    
				                }
				            },
				           
				        }
				    ]
				};
		 myChart4.setOption(option4);
		 
		 //生态物种柱状图
		  var myChart5= echarts.init(document.getElementById('species'));
		  var option5= {
				  title: {
				      
				    }, 
		 	
				  tooltip: {
				        trigger: 'axis',
				        axisPointer: {
				            type: 'shadow'
				        }
				    },
				    legend: {
				    	top:'5%',
				        data: [{
							name:'国家重点保护物种数（新疆）',
							textStyle:{
								color:'white',
								fontsize:'25px'
							}
						},{
							name:'新疆物种数', 
							textStyle:{
								color:'white',
								fontsize:'25px'
							}
						}]
				    },
				    grid: {
				        left: '23%',
				        bottom: '23%'
				    },
				    xAxis: [{
				        type: 'value',
						splitLine:{
							show: true,
							 lineStyle:{
										type:'dashed'
				                    },
							},
						 axisLine: {
				                    show: false,
				                    lineStyle:{
				                        fontSize:'25px',
				                        color:'white',
										padding:'50px',
														
				                    },
				            },
				        boundaryGap: [0, 0.01]
				    }],
				    yAxis:[ {
				        type: 'category',
						 axisLine: {
				                    show: false,
				                    lineStyle:{
				                        fontSize:'20px',
				                        color:'white',
				                    }				
				            },
				        data: ['植物','鸟类','两栖爬行类','鱼类','哺乳类']
				    }, {
				        type: 'category',
						        axisLine: {show:false},
				                axisTick: {show:false},
				                axisLabel: {show:false},
				                splitArea: {show:false},
				                splitLine: {show:false},
				        data: ['植物','鸟类','两栖爬行类','鱼类','哺乳类']
				    }],
				    series: [
				        {
				            name: '国家重点保护物种数（新疆）',
				            type: 'bar',
							yAxisIndex:1,
							barWidth : 15,
				            itemStyle:{
				                normal: {
				                    show: true,
				                    color: '#5a9a9a'
				                }
				            },
				            data: [{
				        		value:54,
				        		itemStyle: {
				                    normal: {
				                        color: {
				                            type: 'bar',
				                            colorStops: [{
				                                offset: 0,
				                                color: 'rgba(90,154,154,0)' // 0% 处的颜色
				                            }, {
				                                offset: 1,
				                                color: 'rgba(90,154,154,1)' // 100% 处的颜色
				                            }],
				                        }
				                    }
				                }
				            },{
				        		value:73,
				        		itemStyle: {
				                    normal: {
				                        color: {
				                            type: 'bar',
				                            colorStops: [{
				                                offset: 0,
				                                color: 'rgba(90,154,154,0)' // 0% 处的颜色
				                            }, {
				                                offset: 1,
				                                color: 'rgba(90,154,154,1)' // 100% 处的颜色
				                            }],
				                        }
				                    }
				                }
				            },{
				        		value:1,
				        		itemStyle: {
				                    normal: {
				                        color: {
				                            type: 'bar',
				                            colorStops: [{
				                                offset: 0,
				                                color: 'rgba(90,154,154,0)' // 0% 处的颜色
				                            }, {
				                                offset: 1,
				                                color: 'rgba(90,154,154,1)' // 100% 处的颜色
				                            }],
				                        }
				                    }
				                }
				            },{
				        		value:21,
				        		itemStyle: {
				                    normal: {
				                        color: {
				                            type: 'bar',
				                            colorStops: [{
				                                offset: 0,
				                                color: 'rgba(90,154,154,0)' // 0% 处的颜色
				                            }, {
				                                offset: 1,
				                                color: 'rgba(90,154,154,1)' // 100% 处的颜色
				                            }],
				                        }
				                    }
				                }
				            },{
				        		value:14,
				        		itemStyle: {
				                    normal: {
				                        color: {
				                            type: 'bar',
				                            colorStops: [{
				                                offset: 0,
				                                color: 'rgba(90,154,154,0)' // 0% 处的颜色
				                            }, {
				                                offset: 1,
				                                color: 'rgba(90,154,154,1)' // 100% 处的颜色
				                            }],
				                        }
				                    }
				                }
				            }],
				        },
				        {
				            name: '新疆物种数',
				            type: 'bar',
				            barWidth : 15,
				            itemStyle:{
				                normal: {
				                    show: true,
				                    color: 'rgba(0,0,0,0)',
									borderColor:'#7bb2e4'
				                }
				            },
				            data: [1476, 360,76,200,40],
				        }
				    ]
				};
		  myChart5.setOption(option5);
		 
		 

	//实时数据获取
		var wetlandName='';
		var siteId='';
		var collectionDataList=[];
		function getRealTimeData(){
			$('#data1').empty();
			$('#data2').empty();
			$('#wetlandName').empty();
			$.ajax({
				url : "../datacollection/findNewestByRandomWetlandForBD",			
				type : "POST",
				data : { "wetlandName":'',"siteId":''},		
				error : function(error) {
					console.log(error.responseText);
				},
				success : function(res) {
					//wetlandName=res.wetlandName;
					//siteId=res.siteId;
					collectionDataList=res.collectionDataList;
					res.collectionDataList.map(function(item){
						switch(item.para) {
		                  case '气温':
		                    item.feeling = Degree(item.value)[0];	                              
		                    break;
		                  case '湿度':
		                    item.feeling = Wet(item.value)[0];
		                  
		                    break;
		                  case 'pm2.5':
		                  case 'pM2.5':
		                  case 'Pm2.5':
		                  case 'PM2.5':
		                    item.feeling = PM(item.value)[0];
		                    
		                    break;
		                  case '噪音':
		                    item.feeling = Noise(item.value)[0];
		                   
		                    break;
		                  case '风速':
		                    item.feeling = WindSpeed(item.value)[0];
		                   
		                    break;
		                  case '风向':
		                    item.feeling = WindDirection(item.value)[0];
		                    
		                    break;
		                  case 'pH':
		                  case 'PH':
		                  case 'Ph':
		                    item.feeling = PH(item.value)[0];
		                      
		                    break;
		                  case '浊度':
		                    item.feeling = Dimness(item.value)[0];
		                    
		                    break;
		                  case '溶解氧':
		                  case '溶氧':
		                    item.feeling = Disoxy(item.value)[0];
		                    i
		                    break;
		                  case '总磷':
		                    item.feeling = Phosphorus(item.value)[0];
		                   
		                    break;
		                  case '总氮':
		                    item.feeling = Nitrogen(item.value)[0];
		                   
		                    break;
		                  case 'COD':
		                  case 'cod':
		                  case 'Cod':
		                    item.feeling = COD(item.value)[0];
		                   
		                    break;
		                  case '水质':
		                    item.feeling = Water(item.value)[0];
		                    
		                    break;
		                  case '水温':
		                    item.feeling = WaterTemperature(item.value)[0];
		                   
		                    break; 
		                  case '氨氮':
		                    item.feeling = NH3(item.value)[0];
		                   
		                    break;
		                  case '高锰酸盐指数':
		                    item.feeling = Permanganate(item.value)[0];
		                   
		                    break;
		                  case '电导率':
		                    item.feeling = Conductivity(item.value)[0];
		                   
		                    break;
		                  case 'ORP':
		                  case 'orp':
		                    item.feeling = ORP(item.value)[0];
		                   
		                    break;
		                  case '盐度':
		                    item.feeling = Salinity(item.value)[0];
		                    
		                    break;
		                  case '透明度':
		                    item.feeling = Opacity(item.value)[0];
		                   
		                    break;
		                  case '叶绿素a':
		                    item.feeling = Chlorophyll(item.value)[0];
		                    
		                    break;
		                  case '挥发酚':
		                    item.feeling = Phenol(item.value)[0];
		                   
		                    break;
		                  case '砷':
		                    item.feeling = Arsenic(item.value)[0];
		                   
		                    break;
		                  case '降雨量':
		                    item.feeling = Rainfall(item.value)[0];
		                    
		                    break;
		                  case '日照时数':
		                    item.feeling = Sunshine(item.value)[0];
		                    
		                    break;
		                  case '紫外辐射':
		                    item.feeling = Ultraviolet(item.value)[0];
		                   
		                    break;
		                  case '光照强度':
		                    item.feeling = Bright(item.value)[0];
		                   
		                    break;
		                  case 'SO2':
		                  case 'so2':
		                  case 'So2':
		                    item.feeling = SO2(item.value)[0];
		                    
		                    break;
		                  case 'PM10':
		                  case 'pm10':
		                  case 'Pm10':
		                    item.feeling = PM10(item.value)[0];
		                   
		                    break;
		                  case '臭氧':
		                    item.feeling = Ozone(item.value)[0];
		                    
		                    break;
		                  case '土壤电导率':
		                    item.feeling = SEC(item.value)[0];
		                   
		                    break;
		                  case '土壤湿度':
		                    item.feeling = SW(item.value)[0];
		                    
		                    break;
		                  case '土壤盐度':
		                    item.feeling = SS(item.value)[0];
		                   
		                    break;
		                  case '有机质':
		                    item.feeling = Organic(item.value)[0];
		                    
		                    break;
		                  case '速效磷':
		                    item.feeling = AP(item.value)[0];
		                   
		                    break;
		                  case '速效钾':
		                    item.feeling = Potassium(item.value)[0];
		                    
		                    break;
		                  case 'NO2':
		                  case 'no2':
		                  case 'No2':
		                    item.feeling = NO2(item.value)[0];
		                   
		                    break;
		                  case 'CO':
		                  case 'co':
		                  case 'Co':
		                    item.feeling = CO(item.value)[0];
		                   
		                    break;
		                  case '负氧离子':
		                    item.feeling = Oxygen(item.value)[0];
		                    
		                    break;
		                  default:
		                    item.feeling = '';
		                   
		                }
					});
					
					var data=res.collectionDataList;
					var length=data.length;
					  
					$('#wetlandName').append(res.wetlandName+'/'+res.siteName);
					$('#wetlanddatas').empty();
					for(var i=0;i<data.length;i++){ 
						var num=i+1;
						if(i%6==0){
							$('#wetlanddatas').append("<tr style='background:rgba(255, 255, 255, 0.05);height:39px;'><td style='background-color:#516d79;'>"+num+"</td><td>"+data[i].para+"</td><td style='color:#516d79'>"+data[i].value+data[i].unit+"</td><td>"+data[i].feeling+"</td></tr>");
						}else if(i%6==1){
							$('#wetlanddatas').append("<tr style='height:39px;'><td style='background-color:#475a69;'>"+num+"</td><td>"+data[i].para+"</td><td style='color:#475a69'>"+data[i].value+data[i].unit+"</td><td>"+data[i].feeling+"</td></tr>");
						}else if(i%6==2){
							$('#wetlanddatas').append("<tr style='background: rgba(255, 255, 255, 0.05);height:39px;'><td style='background-color:#8c6b68;'>"+num+"</td><td>"+data[i].para+"</td><td style='color:#8c6b68'>"+data[i].value+data[i].unit+"</td><td>"+data[i].feeling+"</td></tr>");
						}else if(i%6==3){
							$('#wetlanddatas').append("<tr style='height:39px;'><td style='background-color:#68555b;'>"+num+"</td><td>"+data[i].para+"</td><td style='color:#68555b'>"+data[i].value+data[i].unit+"</td><td>"+data[i].feeling+"</td></tr>");
						}else if(i%6==4){
							$('#wetlanddatas').append("<tr style='background: rgba(255, 255, 255, 0.05);height:39px;'><td style='background-color:#516d79;'>"+num+"</td><td>"+data[i].para+"</td><td style='color:#516d79'>"+data[i].value+data[i].unit+"</td><td>"+data[i].feeling+"</td></tr>");
						}else if(i%6==5){
							if(length<=6){
								$('#wetlanddatas').append("<tr style='height:39px;'><td>"+num+"</td><td>"+data[i].para+"</td><td style='color:#475a69'>"+data[i].value+data[i].unit+"</td><td>"+data[i].feeling+"</td></tr>");
							}else if(length>6 && i==5){
								$('#wetlanddatas').append("<tr style='height:39px;'><td><img src='../js/homeinformation/images/icon.png' width=40 height=40 ></td><td>"+data[i].para+"</td><td style='color:#475a69'>"+data[i].value+data[i].unit+"</td><td>"+data[i].feeling+"</td></tr>");
							} 
						}					
						  
					}
					
					
				}
			});
		}
		
			getRealTimeData();

			setInterval(getRealTimeData,10000);  

			
			
		$('#down').on('click',function(){
			document.getElementsById('datas')[0].scrollTop=document.getElementsById('datas')[0].scrollHeight;
		});	
	

    //地图
    var sites =new Array();
 	var stamen;

	require(["esri/Basemap"], function(Basemap) { 
		
	});
	require([
	"esri/Map",
	"esri/views/MapView",
	"esri/views/ui/UI", 
	"esri/layers/FeatureLayer",
	"esri/Graphic",
	"esri/widgets/BasemapToggle",
	"esri/layers/MapImageLayer",
	"dojo/domReady!"
	], function(Map, MapView,UI, FeatureLayer,Graphic,BasemapToggle,MapImageLayer){  
	  var view;
	  var layer = new MapImageLayer({
		    url: "http://58.213.118.50:6080/arcgis/rest/services/行政边界_新疆/新疆市级行政边界/MapServer/"
		  });
	  var map = new Map({ 
		  basemap:"dark-gray", 
		}); 
	  map.add(layer);
	  
	  function createView(map) {
	       view = new MapView({
	        map: map,
	        container: "map",
	        zoom: 7,  
		    center: [83.261539,43.236485],
		    popup: {
		          dockEnabled: true,
		          dockOptions: {
		            // Disables the dock button from the popup
		            buttonEnabled: true,
		            // Ignore the default sizes that trigger responsive docking
		            breakpoint: true,
		          }
		        }
	      });
	       
	  }
	createView(map);
	var basemapToggle = new BasemapToggle({
		  view: view,  // The view that provides access to the map's "streets" basemap
		  nextBasemap: "hybrid"  // Allows for toggling to the "hybrid" basemap
		});
	view.ui.add(basemapToggle, "top-right");

	view.popup.set("dockOptions", {
	    breakpoint: true,
	    buttonEnabled: true,
	    position:'top-left'
	  });
	
	function getSiteInfo(target){
		  var result='';
		  $.ajax({
			  url:'../wetlandManager/findbyid',
			  type:'POST',
			  data:{"id":target.graphic.attributes.ID}, 
			  async:false,
			  success:function(res){
				  var data="<p>行政区划: <span class='value'>"+res.wlin_province+res.wlin_city+res.wlin_district+"</span></p>"
				 	+"<p>湿地面积: <span class='value'>"+res.wlin_official_area+"公顷</span></p>"
				 	+"<p>保护体系: <span class='value'>"+res.wlin_protection_level+"</span></p>"
				 	+"<p>管理单位:<span class='value'>"+res.wlin_management_name+"</span></p>";
				 var src="<p><a href='javascript:showinfo(\""+ target.graphic.attributes.ID + "\")'>查看详情</a></p>"
				  result=data+src; 
			  },
			  error:function(err){
				  return err;
			  }
		  });
		  return result;
	} 







	//渲染所有监测点
	$.ajax({
		url:'../wetlandManager/calculatecenterandscaleForBD',
		type:'POST',
		success:function(res){
			res.forEach(function(item){ 
				var point=coordtransform.bd09togcj02(item.wlin_longitude,item.wlin_latitude);	
				var points = coordtransform.gcj02towgs84(point[0], point[1]);
				var polyline = {
						 type: "point",  
						 longitude:points[0].toFixed(6),
						 latitude: points[1].toFixed(6)
				  };							
				// Create an object for storing attributes related to the line
				 var lineAtt = {
				          名字: item.wlin_name,
				          ID: item.id,				    
				  };
				 var textSymbol ={
				    	  type: "text",  // autocasts as new TextSymbol()
				    	  color: "white",
				    	  haloColor: "black",
				    	  haloSize: "1px",
				    	  text: item.wlin_name,
				    	  xoffset: 8, 
				    	  yoffset: 10,
				    	  font: {  // autocast as new Font()
				    	    size: 10,
				    	    family: "sans-serif",
				    	    weight: "bolder"
				    	  }
				    };	
		 
				 
				 var polylineGraphic1 = new Graphic({
					geometry: polyline,
				    symbol:{
				    	  type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
						  color: '#FF4040',
						  outline: { // autocasts as new SimpleLineSymbol()
						  color: [255, 255, 255],
						  width: 2
						  }		
				    },
				    attributes: lineAtt,
				    popupTemplate: {  // autocasts as new PopupTemplate()
						title: "{名字}",
				/*		content: [{
						   type: "fields",
						   fieldInfos: [{fieldName: "名字"}, {fieldName: "ID"}]
						}]   */
						content:getSiteInfo
					 }
				 });
				 
				
				 
				 var polylineGraphic2 = new Graphic({
						geometry: polyline,
					    symbol: {
					    	  type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
							  color: '#00BFFF',
							  outline: { // autocasts as new SimpleLineSymbol()
							  color: [255, 255, 255],
							  width: 2
							  }		
					    },
					    attributes: lineAtt,
					    popupTemplate: {  // autocasts as new PopupTemplate()
							title: "{名字}",
					/*		content: [{
							   type: "fields",
							   fieldInfos: [{fieldName: "名字"}, {fieldName: "ID"}]
							}]   */
							content:getSiteInfo
						 }
					 });
				 var polylineGraphic3 = new Graphic({
						geometry: polyline,
					    symbol: {
					    	  type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
							  color: '#00FF00',
							  outline: { // autocasts as new SimpleLineSymbol()
							  color: [255, 255, 255],
							  width: 2
							  }		
					    },
					    attributes: lineAtt,
					    popupTemplate: {  // autocasts as new PopupTemplate()
							title: "{名字}",
					/*		content: [{
							   type: "fields",
							   fieldInfos: [{fieldName: "名字"}, {fieldName: "ID"}]
							}]   */
							content:getSiteInfo
						 }
					 });
				 var polylineGraphic4 = new Graphic({
						geometry: polyline,
					    symbol: {
					    	  type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
							  color: '#00EEEE',
							  outline: { // autocasts as new SimpleLineSymbol()
							  color: [255, 255, 255],
							  width: 2
							  }		
					    },
					    attributes: lineAtt,
					    popupTemplate: {  // autocasts as new PopupTemplate()
							title: "{名字}",
					/*		content: [{
							   type: "fields",
							   fieldInfos: [{fieldName: "名字"}, {fieldName: "ID"}]
							}]   */
							content:getSiteInfo
						 }
					 });
				 var polylineGraphic5 = new Graphic({
						geometry: polyline,
					    symbol: {
					    	  type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
							  color: '#B7B7B7',
							  outline: { // autocasts as new SimpleLineSymbol()
								  color: [255, 255, 255],
								  width: 2
							  }
							
					    },
					    attributes: lineAtt,
					    popupTemplate: {  // autocasts as new PopupTemplate()
							title: "{名字}",
					/*		content: [{
							   type: "fields",
							   fieldInfos: [{fieldName: "名字"}, {fieldName: "ID"}]
							}]   */
							content:getSiteInfo
						 }
					 });
				 
				 var polylineGraphics = new Graphic({
						geometry: polyline,
					    symbol:textSymbol,
					    attributes: lineAtt,
					    popupTemplate: {  // autocasts as new PopupTemplate()
							title: "{名字}",
					/*		content: [{
							   type: "fields",
							   fieldInfos: [{fieldName: "名字"}, {fieldName: "ID"}]
							}]   */
							content:getSiteInfo
						 }
					 });
				if(item.wlin_protection_level=='国际重要湿地'){
					view.graphics.add(polylineGraphic1);
				}else if(item.wlin_protection_level=='国家重要湿地'){
					view.graphics.add(polylineGraphic2);
				}else if(item.wlin_protection_level=='一般湿地'){
					view.graphics.add(polylineGraphic3);
				}else if(item.wlin_protection_level=='市级重要湿地'){
					view.graphics.add(polylineGraphic4);
				}else if(item.wlin_protection_level=='省级重要湿地'){
					view.graphics.add(polylineGraphic5);
				}else if(item.wlin_protection_level=='其它'){
					view.graphics.add(polylineGraphic5);
				} 	 		 	 				 			
				// Add the line graphic to the view's GraphicsLayer
				
				view.on("mouse-wheel", function(evt){
					 // deltaY value is postive when wheel is scrolled up
					 // and it is negative when wheel is scrolled down.
					 console.log(view.zoom);
						if(view.zoom>=10){
							view.graphics.add(polylineGraphics);
						}else if(view.zoom<=9){
							view.graphics.remove(polylineGraphics);
						}
					}); 

			})
			
		},
		error:function(err){
			console.log(err);
		}
		});  
	function showbywetlandname(wetlandname){
		//根据湿地公园名称获取视频监测点数据
		getsitesbywetlandname(wetlandname);
		//根据湿地公园名称进行地图展示
		showmapbywetlandname(wetlandname);
	}

		$('#select').on('change',function(){
			var wetland=$(this).val();
			var arr=wetland.split('_');
			showbywetlandname(arr[0]);
		});
		
		
		
		/**
		 * 根据湿地公园名称获取视频监测点信息
		 */
		function getsitesbywetlandname(wetlandname) {
			$.ajax({
				url : "../monitoringsite/findsiteinfobywetlandname",
				dataType : "json",
				type : "POST",
				data : {'wetlandname':wetlandname},
				async : false,
				error : function(error) {
					console.log(error.responseText);
					$.gritter.add({
						title : '服务器错误',
						text : '对起，服务器错误，请联系系统管理员！',
						class_name : 'gritter-error'
					});
				},
				success : function(strValue) {
					sites.length = 0;
					for ( var key in strValue) {
						if (strValue[key].show == 1){
							sites.push({
								"longitude" : strValue[key].longitude,
								"latitude" : strValue[key].latitude,
								"id" : key,
								"name" : strValue[key].name,
								"status" : strValue[key].status
							});	
						}
					}
				}
			});
		}

		function showmapbywetlandname(wetlandname) {
			var centerlongitude, centerlatitude, zoom;
			$.ajax({
				url : "../wetlandManager/findbyname",
				dataType : "json",
				type : "POST",
				data : {'name':wetlandname},
				async : false,
				error : function(error) {
					console.log(error.responseText);
					$.gritter.add({
						title : '服务器错误',
						text : '对不起，服务器错误，请联系系统管理员！',
						class_name : 'gritter-error'
					});
				},
				success : function(strValue) {
					centerlongitude = strValue.wlin_longitude;
					centerlatitude = strValue.wlin_latitude;
					view.goTo({
						  center: [centerlongitude, centerlatitude],
						  zoom: 10
						}); 
					 var polyline = {
							 type: "point",  
							 longitude: centerlongitude,
							 latitude: centerlatitude
					  };		
					 var textSymbol ={
					    	  type: "text",  // autocasts as new TextSymbol()
					    	  color: "white",
					    	  haloColor: "black",
					    	  haloSize: "1px",
					    	  text: wetlandname,
					    	  xoffset: 8, 
					    	  yoffset: 10,
					    	  font: {  // autocast as new Font()
					    	    size: 10,
					    	    family: "sans-serif",
					    	    weight: "bolder"
					    	  }
					    };	
					 var polylineGraphics = new Graphic({
							geometry: polyline,
						    symbol:textSymbol						  
						 });
					 view.graphics.add(polylineGraphics);
					 
					 view.on("mouse-wheel", function(evt){
							if(view.zoom<=9){
									view.graphics.remove(polylineGraphics);
								}
							}); 

				}
			});
		}
	});
	
	// 启动显示
	function showinfo(id) {
		window.location.href='../wetlandManager/indexnew?id='+id;
	}

